<?php
namespace backend\components;
use Yii;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\helpers\Html;
/**
 * Class Menu
 * Theme menu widget.
 */
class ManageMenu
{
    public static $menu = array(
        '单页管理'=>[
            'url'=>['manage/index'],
            'spanclass'=>'fa arrow',
            'iclass'=>'fa fa-th-list',
        ],
        '小喇叭管理'=>[
            'url'=>['manage/notice'],
            'spanclass'=>'fa arrow',
            'iclass'=>'fa fa-th-list',
        ],
        '独家管理'=>[
            'url'=>['manage/cate'],
            'spanclass'=>'fa arrow',
            'iclass'=>'glyphicon glyphicon-object-align-left',
        ],
        '会员管理'=>[
            'url'=>['manage/user'],
            'spanclass'=>'fa arrow',
            'iclass'=>'glyphicon  glyphicon-thumbs-up',
        ],
        '反馈管理'=>[
            'url'=>['manage/fankui'],
            'spanclass'=>'fa arrow',
            'iclass'=>'glyphicon  glyphicon-thumbs-up',
        ],
        '焦点图管理'=>[
            'url'=>['manage/jiaodian'],
            'spanclass'=>'fa arrow',
            'iclass'=>'glyphicon  glyphicon-thumbs-up',
        ],
        '消息模板管理'=>[
            'url'=>['manage/message'],
            'spanclass'=>'fa arrow',
            'iclass'=>'glyphicon  glyphicon-thumbs-up',
        ],

    );
    public static function render()
    {
        self::initMenuByRole();
        $left='';
        foreach(self::$menu as $key=>$value) {
            $href = Url::to($value['url']);
            $iclass = $value['iclass'];
            $spanclass = $value['spanclass'];
            $left.= <<<LEFT
            <li>
                <a href="{$href}"><i class="{$iclass}"></i> {$key}<span class="{$spanclass}"></span></a>
            </li>
LEFT;

        }
        return $left;
    }

    public static function initMenuByRole()
    {
        $roles = Yii::$app->authManager->getRolesByUser(Yii::$app->user->id);
        $role = array_shift($roles);
        if($role->name=='查看会员渠道组') {
            self::$menu = array(
                '会员管理'=>[
                    'url'=>['manage/user'],
                    'spanclass'=>'fa arrow',
                    'iclass'=>'glyphicon  glyphicon-thumbs-up',
                ],

            );
        }
    }

}
